package com.mumu.muPictureBackend.model.enums;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

@Getter
public enum SpaceEnum {
    //定义三个枚举 对应三个等级
    COMMON("普通版", 0, 100, 100L * 1024 * 1024),
    PROFESSIONAL("专业版", 1, 1000, 1000L * 1024 * 1024),
    FLAGSHIP("旗舰版", 2, 10000, 10000L * 1024 * 1024);
    private final String text;
    private final int value;
    private final long maxCount;
    private final long maxSize;

    SpaceEnum(String text, int value, long maxCount, long maxSize) {
        this.text = text;
        this.value = value;
        this.maxCount = maxCount;
        this.maxSize = maxSize;
    }


    static final Map<Integer, SpaceEnum> hashMap = new HashMap<>();

    //hash化 要利用value等级快速获取枚举
    static {
        for (SpaceEnum value : SpaceEnum.values()) {
            hashMap.put(value.getValue(), value);
        }
    }

    //利用hash快速获取等级对应的空间
    public static SpaceEnum getSpaceLevel(Integer level) {
        return hashMap.get(level);
    }
}






